﻿if (typeof Axis == "undefined") Axis = {};
if (typeof Axis.View == "undefined") Axis.View = {};
if (typeof Axis.View.Banner == "undefined") Axis.View.Banner = {};
Axis.View.Banner.List = {
    Init: function () {
        this.GetList();
    },
    GetList: function () {
        var thisObj = this;
        if (typeof CateID == 'undefined') var CateID=0;
        var pData = '{' + $.string.Format('"CateID":{0}', CateID) + '}';
        $.ajax({
            url: '../Banner/Service/BannerService.asmx/GetList',
            type: 'POST',
            data: pData,
            cache: false,
            async: false,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (pData, textStatus, jqXHR) {
                var data = eval("(" + pData.d + ")");
                thisObj.BuildList(data);

            },
            beforeSend: function (jqXHR, settings) {
            },
            error: function (jqXHR, textStatus, errorThrown) {
            },
            complete: function (XMLHttpRequest, textStatus) {
            }
        });

    },
    BuildList: function (data) {
        var objThis = this;
        var pattern = "<img src=\"{1}\" onclick=\"ViewBanner('{0}')\" class=\"linkBanner\" />";
        var htmlContent = "";
        $.each(data, function (index, item) {
            htmlContent += $.string.Format(pattern, item.Url, item.Image);
        });
        $(".banner_box").html(htmlContent);
    }
}
$(function () {
    Axis.View.Banner.List.Init();
});
function ViewBanner(Url) {
    window.location.assign(Url);
}